package Model;

import java.util.Date;

public abstract class Book {
    private String title;
    private String author;
    private String isbn;
    private String genre;
    private int pageCount;
    private double price;
    private Date publicationDate;
    private boolean available;

    private final double baseFine; //罚款

    public Book(String title, String author, String isbn, String genre, int pageCount, double price, Date publicationDate, double baseFine) {
        this.title = title;
        this.author = author;
        this.isbn = isbn;
        this.genre = genre;
        this.pageCount = pageCount;
        this.price = price;
        this.publicationDate = publicationDate;
        this.available = true; // 默认为可借状态
        this.baseFine = baseFine;
    }

    // Getter 和 Setter 方法
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getIsbn() {
        return isbn;
    }

    public void setIsbn(String isbn) {
        this.isbn = isbn;
    }

    public String getGenre() {
        return genre;
    }

    public void setGenre(String genre) {
        this.genre = genre;
    }

    public int getPageCount() {
        return pageCount;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public Date getPublicationDate() {
        return publicationDate;
    }

    public void setPublicationDate(Date publicationDate) {
        this.publicationDate = publicationDate;
    }

    public boolean isAvailable() {
        return available;
    }

    public void setAvailable(boolean available) {
        this.available = available;
    }

    // 借出书籍方法
    public void borrowBook() {
        if (available) {
            available = false;
            System.out.println("Model.Book borrowed: " + title);
        } else {
            System.out.println("Sorry, this book is not available for borrowing.");
        }
    }

    // 归还书籍方法
    public void returnBook() {
        if (!available) {
            available = true;
            System.out.println("Model.Book returned: " + title);
        } else {
            System.out.println("This book is already available.");
        }
    }

    //计算罚款
    public double calculateFine() {
        return baseFine;
    }

    // 显示书籍信息方法
    public abstract void displayInfo();

    public double getBaseFine() {
        return baseFine;
    }
}
